/**   
* @Title: Main.java
* @Package me.paxos.main
* @Description: TODO
* @author xaoyaoyao
* @date Dec 25, 2018 1:49:39 PM
* @version V1.0   
*/
package me.paxos.main;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import me.paxos.doer.Acceptor;
import me.paxos.doer.Proposer;

/**
 * @ClassName: Main
 * @Description: TODO
 * @author xaoyaoyao
 * @date Dec 25, 2018 1:49:39 PM
 * 
 */
public class Main {

	private static final int NUM_OF_PROPOSER = 5;
	private static final int NUM_OF_ACCEPTOR = 7;
	public static CountDownLatch latch = new CountDownLatch(NUM_OF_PROPOSER);;

	public static void main(String[] args) {
		List<Acceptor> acceptors = new ArrayList<>();
		for (int i = 0; i < NUM_OF_ACCEPTOR; i++) {
			acceptors.add(new Acceptor());
		}

		ExecutorService es = Executors.newCachedThreadPool();
		for (int i = 0; i < NUM_OF_PROPOSER; i++) {
			Proposer proposer = new Proposer(i, i + "#Proposer", NUM_OF_PROPOSER, acceptors);
			es.submit(proposer);
		}
		es.shutdown();
	}
}
